home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2008 April / PCgo 2008-04 (DVD).iso / interface / contents / demoversionen_3846 / 13664 / files / Data1.cab / toollist.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-16  |  4.3 KB  |  167 lines

  1. /******************************************************************/
  2. /*                                                                */
  3. /*                      TurboCAD for Windows                      */
  4. /*                   Copyright (c) 1993 - 2001                    */
  5. /*             International Microcomputer Software, Inc.         */
  6. /*                            (IMSI)                              */
  7. /*                      All rights reserved.                      */
  8. /*                                                                */
  9. /******************************************************************/
  10.  
  11. // ToolList.cpp : implementation file
  12. //
  13.  
  14. #include "stdafx.h"
  15. #include "InsSmObj.h"
  16. #include "ToolList.h"
  17. #include "SdiDialog.h"
  18.  
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CExternalObjectsList
  27.  
  28. CExternalObjectsList::CExternalObjectsList()
  29. {
  30. }
  31.  
  32. CExternalObjectsList::~CExternalObjectsList()
  33. {
  34. }
  35.  
  36.  
  37. BEGIN_MESSAGE_MAP(CExternalObjectsList, CListBox)
  38.     //{{AFX_MSG_MAP(CExternalObjectsList)
  39.     ON_WM_MOUSEMOVE()
  40.     ON_WM_LBUTTONUP()
  41.     ON_CONTROL_REFLECT(LBN_SELCHANGE, OnSelchange)
  42.     ON_WM_LBUTTONDOWN()
  43.     //}}AFX_MSG_MAP
  44. END_MESSAGE_MAP()
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CExternalObjectsList message handlers
  48.  
  49. void CExternalObjectsList::OnMouseMove(UINT nFlags, CPoint point) 
  50. {
  51.     // TODO: Add your message handler code here and/or call default
  52.     if(nFlags & MK_LBUTTON)
  53.     {
  54.         
  55.         int dx = m_LB_DOWNpoint.x - point.x;
  56.         int dy = m_LB_DOWNpoint.y - point.y;
  57.         CPoint Pt = point;
  58.  
  59.         if((abs(dx) > 1 || abs(dy) > 1) && m_bDrag)
  60.         {
  61.             // if dragging
  62.             if (((CSdiDialog*)GetParent())->m_dwEventConnection == 0)
  63.             {
  64.                 ((CSdiDialog*)GetParent())->ConnectEvents();
  65.             }
  66.                 m_OldCursor = GetCursor();
  67.                 m_DragCursor = LoadCursor(AfxGetInstanceHandle( ), MAKEINTRESOURCE(IDC_CURSOR1));
  68.                 SetCursor(m_DragCursor);
  69.                 ShowCursor(TRUE);
  70.                 m_bDrag = FALSE;
  71.                 m_LB_DOWNpoint.x = -1;
  72.                 m_LB_DOWNpoint.y = -1;
  73.                 ((CSdiDialog*)GetParent())->m_DraggingMode = TRUE;
  74.                 return;
  75.             
  76.         }
  77.  
  78.         ClientToScreen(&Pt);
  79.         CWnd *pClickWNd = WindowFromPoint(Pt);
  80.  
  81.         if(pClickWNd && pClickWNd != this)
  82.         {
  83.             pClickWNd->ScreenToClient(&Pt);
  84.             pClickWNd->PostMessage(WM_MOUSEMOVE, nFlags, MAKELONG(Pt.x, Pt.y));
  85.         }
  86.     }
  87. }
  88.  
  89.  
  90.  
  91. void CExternalObjectsList::OnLButtonUp(UINT nFlags, CPoint point) 
  92. {
  93.     CListBox::OnLButtonUp(nFlags, point);
  94.     m_bDrag = FALSE;
  95.  
  96.     CPoint Pt = point;
  97.     ClientToScreen(&Pt);
  98.     CWnd *pClickWNd = WindowFromPoint(Pt);
  99.         
  100.     if(pClickWNd && pClickWNd != this)
  101.     {
  102.         pClickWNd->ScreenToClient(&Pt);
  103.         pClickWNd->PostMessage(WM_LBUTTONUP, nFlags, MAKELONG(Pt.x, Pt.y));
  104.         SetCursor(m_OldCursor);
  105.         ShowCursor(TRUE);
  106.         return;
  107.     }
  108.     else
  109.     {
  110.         SetCursor(m_OldCursor);
  111.         ShowCursor(TRUE);
  112.     }
  113. }
  114.  
  115.  
  116. void CExternalObjectsList::OnSelchange() 
  117.  
  118. {
  119.     // TODO: Add your control notification handler code here
  120.     
  121.     CListBox *pList = (CListBox *) (GetParent()->GetDlgItem(IDC_EXTOBJECTSLIST));
  122.  
  123.     HCURSOR hOC = ::SetCursor(::LoadCursor(NULL,IDC_WAIT));
  124.     
  125.     int index = pList->GetCurSel();
  126.     CString cstrSelected;
  127.  
  128.     pList->GetText(index, cstrSelected);
  129.     if (m_cstrCurSelected != cstrSelected) // check if the current selection is changed
  130.     {
  131.         CPreviewWnd *pPreviewWnd = (CPreviewWnd *) (((CSdiDialog*)GetParent())->GetDlgItem(IDC_PREVIEW));
  132.         pPreviewWnd->Clear();
  133. // make preview for just selected external object    
  134.         pPreviewWnd->DoPreview();
  135.         m_cstrCurSelected = cstrSelected;
  136.         pPreviewWnd->Invalidate();
  137.     }
  138.     ::SetCursor(hOC);
  139. }
  140.  
  141. void CExternalObjectsList::OnLButtonDown(UINT nFlags, CPoint point) 
  142. {
  143.     
  144.     BOOL ret;
  145.  
  146.     CListBox::OnLButtonDown(nFlags, point);
  147.     m_bDrag = TRUE; 
  148.     m_LB_DOWNpoint.x = point.x;
  149.     m_LB_DOWNpoint.y = point.y;
  150.  
  151.     CString cstrSelected;
  152.  
  153.     GetText(ItemFromPoint(point, ret), cstrSelected);
  154.     
  155.     if (m_cstrCurSelected != cstrSelected) // check if the current selection is changed
  156.     {
  157.         BeginWaitCursor();    
  158.         CPreviewWnd *pPreviewWnd = (CPreviewWnd *) (((CSdiDialog*)GetParent())->GetDlgItem(IDC_PREVIEW));
  159.         pPreviewWnd->Clear();
  160.     
  161.         pPreviewWnd->DoPreview();
  162.         m_cstrCurSelected = cstrSelected;
  163.         pPreviewWnd->Invalidate();
  164.         EndWaitCursor();
  165.     }
  166. }
  167.